<!DOCTYPE html>
<html lang = "en">
<head>
    <meta charset = "UTF-8">
    <title>Title</title>

    <!--=====================================================================-->
    <script>
        //阻止默认事件/默认行为

        window.onload = function() {
            //阻止浏览器的右键菜单弹出
            document.oncontextmenu = function () {
                return false;
            };



            let oTxt = document.getElementById('txt1');

            //阻止文本框中输入a;    输入法不是通过key down来触发的所以没办法阻止
            oTxt.onkeydown = function (ev) {
                if (ev.key === 'a') return false;
            }
        };






    </script>
</head>

<body>

<div>
    <input type = "text" id="txt1">

</div>

</body>
</html>